//
//  YIHeaderView.m
//  一点互助
//
//  Created by rimi on 16/8/20.
//  Copyright © 2016年 shen. All rights reserved.
//

#import "YIHeaderView.h"

@implementation YIHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
       self = [super initWithFrame:frame];
       if (self) {
              [self setBackgroundView];
       }
       return self;
}

-(void)setBackgroundView{
       //背景图片
       UIImageView *backgroundImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kBaseWidth, 220)];
       backgroundImage.image = [UIImage imageNamed:@"个人中心-头像背景"];
       [self addSubview:backgroundImage];
       
       //头像
       UIButton *headPortrait = [UIButton buttonWithType:UIButtonTypeCustom];
       [headPortrait setBackgroundImage:[[UIImage imageNamed:@"个人中心-默认头像"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
       [headPortrait setTitle:@"点击登录注册" forState:UIWindowLevelNormal];
       headPortrait.titleLabel.font = [UIFont systemFontOfSize:14];
       [headPortrait setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
       [headPortrait setTitleEdgeInsets:UIEdgeInsetsMake(0, -20, -100, -20)];

       headPortrait.frame = CGRectMake(kBaseWidth/2 - 30, 70, 70, 70);
       [backgroundImage addSubview:headPortrait];
       
       UIView *backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 220, kBaseWidth, 40)];
       backgroundView.backgroundColor = [UIColor colorWithRed:0.5804 green:0.5294 blue:0.5333 alpha:1.0];
       [self addSubview:backgroundView];
       NSArray *titleArr = [NSArray arrayWithObjects:@"愿望",@"打赏",@"收藏", nil];
       NSArray *imageName = [NSArray arrayWithObjects:@"个人中心-愿望",@"个人中心-打赏",@"个人中心-收藏", nil];
       //选项按钮
       for (int i = 0; i < 3; i++) {
              UIButton *threeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
              threeBtn.frame = CGRectMake(40 + i * 140, 5, 20, 20);
              [threeBtn setTitle:titleArr[i] forState:UIWindowLevelNormal];
              [threeBtn setBackgroundImage:[UIImage imageNamed:imageName[i]] forState:UIWindowLevelNormal];
              
              threeBtn.titleLabel.font = [UIFont systemFontOfSize:10];
              [threeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
              [threeBtn setTitleEdgeInsets:UIEdgeInsetsMake(10, -15, -20, -15)];
              
              [backgroundView addSubview:threeBtn];
       }
       
}

@end
